Skip to content

Data streams v2 (1/5): conformance test harness - #329

Open
1egoman wants to merge 5 commits into
mainfrom
ds/1-test-harness
Open

1egoman wants to merge 5 commits into
mainfrom
ds/1-test-harness

Conversation

@1egoman

@1egoman 1egoman commented Nov 30, 2026 •

Copy link
Copy Markdown

Part 1 of 5 of the data streams v2 stack. Merge in order; each part is mergeable on its own.

  1. Data streams v2 (1/5): conformance test harness #329: Conformance test harness 👈 this PR
  2. Data streams v2 (2/5): read incoming data streams through FFI readers #330: Read incoming data streams through FFI readers (fixes receiving from other SDKs)
  3. Data streams v2 (3/5): add sendText / sendBytes / sendFile #331: Add sendText / sendBytes / sendFile
  4. Data streams v2 (4/5): add ByteStreamReader::writeToFile and a receive size limit #332: Add ByteStreamReader::writeToFile and a receive size limit
  5. Data streams v2 (5/5): move writers to FFI writer handles; add streamText / streamBytes #333: Move writers to FFI writer handles; add streamText / streamBytes

This stack replaces #321, #322 and #325 (same code, reordered so each step stands on its own).

Adds the helpers for end-to-end data stream tests ported from the Rust livekit-data-stream crate, plus the 5 receive tests that already pass on main. There's no SDK change. The rest of the stack adds the remaining ported tests next to the code that makes them pass.

Helpers (src/tests/common/data_stream_test_utils.h)

  • FfiPeer drives the other participant through the raw FFI, so it sends exactly what Python, Unity and the other FFI-based SDKs send:
    • its one-shot sends and writers go through the Rust outgoing manager (data streams v2: inline and compressed streams);
    • its raw header / chunk / trailer requests send hand-built v1 packets.
  • RawPacketSniffer records the raw stream packets a room receives. The raw header event carries neither inline_content nor compression, so:
    • "inline" means a header arrived with no chunk or trailer packets;
    • "compressed" means the chunk bytes differ from the payload and are smaller.
  • TextStreamCollector / ByteStreamCollector receive through the public C++ API and record content, info and errors.
  • The helpers use only API that exists on main, so the receive tests in part 2 build against both the old and new receive paths.

Also:

  • scripts/set-test-tokens.sh now mints an optional LIVEKIT_TOKEN_C (cpp-test-c) for tests that need a third participant. Tests that need it skip without it. CI already sources the script.
  • RoomTestAccess::roomHandleId is added.

Tests

test_data_stream_conformance_receive_v1.cpp starts with the 5 v1 receive tests that pass on main:

  • v1 text and byte round trips;
  • trailer attributes;
  • empty chunks;
  • a remote writer's trailer attributes.

The other 12 v1 tests fail on main and land in part 2 with the fix.

Verification (local, macOS arm64, livekit-server --dev)

  • Unit tests: 364/364.
  • Full integration suite: 75 pass, 3 fail (see below), 1 skip.
  • Without the fix: the 12 v1 receive tests left out of this PR fail on this branch, which is main plus tests.
  • Every commit builds and passes the unit tests.
  • Formatting: clang-format is clean on all changed files. Docs build OK. The release symbol leak check is OK.
  • The 3 failing integration tests are the DataTrackE2ETest schema tests (DefineAndGetSchema, DefineAndGetCustomSchemaEncoding, DefineDuplicateSchemaFails). They fail on main on this machine too, and the 1 skip is the token-server test.
  • Windows and Linux are covered only by CI.

🤖 Generated with Claude Code

1egoman and others added 2 commits November 30, 2026 14:47
Shared helpers for porting the Rust livekit-data-stream crate's tests to
end-to-end C++ tests:

- FfiPeer drives a room's participant through the raw FFI, so it sends
  exactly what another FFI-based SDK sends: one-shot sends and stream
  writers go through the Rust outgoing manager (data streams v2), and raw
  header/chunk/trailer requests send hand-built v1 packets.
- RawPacketSniffer records the raw stream packets a room receives.
- Text/ByteStreamCollector receive through the public C++ API and record
  content, info and errors.

The harness only uses API that predates the FFI reader/writer port, so
tests built on it compile before and after that port.

Also mint an optional LIVEKIT_TOKEN_C (cpp-test-c) for tests that need a
third participant, and add RoomTestAccess::roomHandleId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ports the incoming-manager tests of the Rust livekit-data-stream crate
that the current C++ receive path already handles: v1 text and byte
round trips, trailer attribute merging, empty chunks, and a remote text
writer's trailer attributes.

The other v1 tests (duplicate chunks, length and gap errors, close
reasons, orphan packets, disconnects) fail on main and land with the
receive-path fix that makes them pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

✅ Memory checks passed.

CI run · Commit 1e7d035

Memory tester results

Iterations: 100
Warmup: 20
Blocking limits: RSS growth ≤ 24 MiB; thread growth ≤ 10.
Advisory limits: RSS growth ≤ 8 MiB; thread growth ≤ 0.

Scenario RSS 0→20 RSS 20→100 Threads 0→20 Threads 20→100 Status
audio-track +17.82 MiB +0.22 MiB +7 0 ✅ PASS
video-track +18.61 MiB -0.17 MiB +7 0 ✅ PASS
data-track +13.82 MiB +0.31 MiB +1 0 ✅ PASS
room-reuse +13.61 MiB +0.18 MiB +1 0 ✅ PASS
room-client-leave +13.70 MiB +0.23 MiB +1 0 ✅ PASS
room-server-delete +16.25 MiB +0.17 MiB +1 0 ✅ PASS
capture-clock +119.12 MiB +0.60 MiB +7 0 ✅ PASS
capture-pattern +113.48 MiB +2.36 MiB +7 0 ✅ PASS
capture-gstreamer +35.52 MiB +1.38 MiB +9 0 ✅ PASS

#include "ffi_client.h"
#include "room.pb.h"
#include "room_test_access.h"
#include "test_common.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this util implementation is too large to be in the header file, which could slow down the build time as these large #include could transitively increase the number of headers for parsing.

I am going to split the impl to a .cpp file instead.

Stop accepting streams under the worker mutex before unregistering handlers and claiming reader threads. Add deterministic text and byte regressions that invoke saved handlers after collector destruction and verify reader release.
@xianshijing-lk
xianshijing-lk marked this pull request as ready for review December 3, 2026 00:04
@xianshijing-lk
xianshijing-lk requested a review from a team as a code owner December 3, 2026 00:04

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 4 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants